package com.IClass.IActivity;



import com.IClass.App.IClass;
import com.IClass.App.R;
import com.ant.liao.GifView;
import com.ant.liao.GifView.GifImageType;



import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.view.Window;


public class SplashActivity extends Activity {
	public static String TAG = "SplashActivity";
	private final int SPLASH_DISPLAY_LENGHT = 3000; //延迟三秒 
	private static int START_FIRSTOPEN = 1000;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		super.onCreate(savedInstanceState);
		this.setContentView(R.layout.splash_layout);
		//final TypegifView view = (TypegifView) findViewById(R.id);
		// 从xml中得到GifView的句柄
		GifView gf1 = (GifView) findViewById(R.id.splash_gif);
		// 设置Gif图片源
		gf1.setGifImage(R.drawable.ioclass18);
		

		//IClass.classapi.Register("su112wei6","maikkk", "su112wei6@163.com");
		//gf1.set
		// 添加监听器
		//gf1.setOnClickListener(this);
		// 设置显示的大小，拉伸或者压缩
		//gf1.setShowDimension(600, 600);
		// 设置加载方式：先加载后显示、边加载边显示、只显示第一帧再显示
		//gf1.setGifImageType(GifImageType.COVER);
		new Thread() {
            @Override
            public void run() {
            	
				//IClass.classapi.GetHotBlogs();
            	try {
					sleep(3000);
				} catch (InterruptedException e) {
					// FIXME Auto-generated catch block
					e.printStackTrace();
				}
				
				// 加载数据后向主线程发送一个消息启动另个画面
				Message msg = new Message();
				msg.what = SplashActivity.START_FIRSTOPEN;
				handler.sendMessage(msg);
            }
        }.start();
        
		// 向当前线程加入一个信息处理 可以延迟
//        new Handler().postDelayed(new Runnable(){ 
//
//            @Override 
//            public void run() { 
//                
//                
//            } 
//               
//           }, SPLASH_DISPLAY_LENGHT); 
	}
	public Handler handler = new Handler() {

		@Override
		public void handleMessage(Message msg) {
			// FIXME Auto-generated method stub
			super.handleMessage(msg);
			
			if(msg.what == SplashActivity.START_FIRSTOPEN)
			{
				Intent mainIntent = new Intent(SplashActivity.this,IMainViewActivity.class); 
                startActivity(mainIntent);    //启动Main界面
                finish();
			}
		}
		
	};
}
